package copyengine.utils.delayEffect.effect.basic
{
	import copyengine.utils.delayEffect.effect.ICEDelayEffect;

	/**
	 * <b>可以添加BranchEffect的基类</b>
	 * </br></br>该类为Internal,外部不可以直接New出该类的实例
	 */
	internal class CEDelayContainBranchEffectBasic extends CEDelayEffectBasic
	{
		/**
		 * 枝干EffectVector，枝干上面的Effect按照add的顺序，一个接着一个播放
		 */
		protected var subBranchEffectVector:Vector.<ICEDelayEffect>;

		public function CEDelayContainBranchEffectBasic()
		{
			subBranchEffectVector = new Vector.<ICEDelayEffect>();
			super();
		}

		public final function addSubBranchEffect(_effect:ICEDelayEffect):void
		{
			subBranchEffectVector.push(_effect);
		}

		//=========================================//
		//==                        Protected Function                                ==//
		//=========================================//

		override final protected function doExecute():void
		{
			for each (var branchEffect:ICEDelayEffect in subBranchEffectVector)
			{
				branchEffect.setLayer(sceneUILayer, sceneLayer, globalUILayer);
			}
			startExecuteTrunkLogic();
		}

		override final protected function doFinishExecuteImmeditely():void
		{
			for each (var branchEffect:ICEDelayEffect in subBranchEffectVector)
			{
				if (!branchEffect.isExecuteFinish())
				{
					branchEffect.finishExecuteImmediately();
				}
			}
		}

		override final public function onFlowExecuteFinish():void
		{
			for each (var branchEffect:ICEDelayEffect in subBranchEffectVector)
			{
				branchEffect.onFlowExecuteFinish();
			}
		}

		//===========================================//
		//==                      OverrideAble Function                                 ==//
		//===========================================//
		protected function startExecuteTrunkLogic():void
		{
		}

	}
}
